package com.xk857.controller;


import com.xk857.db.CarPartDB;
import com.xk857.pojo.*;
import com.xk857.service.CarPartService;
import com.xk857.service.RoadService;
import com.xk857.util.CarResult;
import com.xk857.util.Result;
import com.xk857.util.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 小车接口模拟 - 8-13
 *
 * @Author Sheepl
 * @Date 2021.1.22
 */
@Api(value = "小车接口模拟",tags = "小车接口 - 杨柳")
@RestController
@RequestMapping("transportservice/type/jason/action")
public class SheeplController {

    @Autowired
    private RoadService roadService;

    @Autowired
    private CarPartService carPartService;

    /**
     * 8. 查询道路拥挤状态
     */
    @ApiOperation("查询道路拥挤状态")
    @GetMapping("GetRoadStatus")
    public Road setCarAction(@RequestParam Integer roadId) {
        Integer crowd = roadService.roadCrowd(roadId);
        return new Road(roadId, crowd);
    }
    /**
     * 9. 停车场子系统 费率设置
     */
    @ApiOperation("停车场子系统 费率设置")
    @PostMapping("SetParkRate")
    public CarResult setParkRate(@RequestBody CarPart carPart) {
        carPartService.setParkRate(carPart.getRateType(), carPart.getMoney());
        return new CarResult("ok");
    }

    /**
     * 10. 停车场子系统 查询当前费率信息
     */
    @ApiOperation("停车场子系统 查询当前费率信息")
    @GetMapping("GetParkRate/{rateType}")
    public CarPart getParkRate(@PathVariable String rateType) {
//        CarPart parkRate = carPartService.getParkRate(rateType);
        return CarPartDB.carPart;
    }

    /**
     * 11. 停车场子系统 查询当前空闲车位
     */
    @ApiOperation("停车场子系统 查询当前空闲车位")
    @GetMapping("GetParkFree")
    public Integer setParkFree() {
        return carPartService.getParkFree();
    }

    /**
     * 12. 查询光照传感器阀值
     */
    @ApiOperation("查询光照传感器阀值")
    @GetMapping("GetLightSenseValve")
    public LightSense setLightSenseValve() {
        return new LightSense(1231,4412);
    }
}
